package com.tbit.uqbike.service.business.impl;

import com.tbit.uqbike.object.pojo.SeparateAccount;
import com.tbit.uqbike.service.business.AdaPayService;
import com.tbit.uqbike.webmanager.dao.core.AdaPayDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName adaPayServiceImpl
 * @Description
 * @date 2021/10/21 14:06
 * @Version 1.0
 */
@Service(value = "adaPayService")
public class adaPayServiceImpl implements AdaPayService {
    @Autowired
    private AdaPayDao adaPayDao;

    @Override
    public Integer addAccount(SeparateAccount separateAccount) {
        return adaPayDao.addAccount(separateAccount);
    }

    @Override
    public Integer updateAccount(SeparateAccount separateAccount) {
        return adaPayDao.updateAccount(separateAccount);
    }

    @Override
    public SeparateAccount getAccount(SeparateAccount separateAccount) {
        Map<String, Object> map = new HashMap<>();
        map.put("accountId", separateAccount.getAccountId());
        map.put("appId", separateAccount.getAppId());
        map.put("memberId", separateAccount.getMemberId());
        return adaPayDao.getAccount(map);
    }

    @Override
    public List<SeparateAccount> getAccountList(Integer accountId, Integer pageNO, Integer rowCount) {
        Map<String, Object> map = new HashMap<>();
        map.put("accountId", accountId);
        if (pageNO != null) {
            map.put("pageNO", (pageNO - 1) * rowCount);
            map.put("rowCount", rowCount);
        }
        return adaPayDao.getAccountList(map);
    }

    @Override
    public Integer getAccountCount(Integer accountId) {
        Map<String, Object> map = new HashMap<>();
        map.put("accountId", accountId);
        return adaPayDao.getAccountCount(map);
    }

    @Override
    public List<SeparateAccount> getAccountByIdNo(SeparateAccount separateAccount) {
        Map<String, Object> map = new HashMap<>();
        map.put("accountId", separateAccount.getAccountId());
        map.put("idNo", separateAccount.getIdNo());
        map.put("bankCard", separateAccount.getBankCard());
        return adaPayDao.getAccountList(map);
    }

    @Override
    public Integer disableAccount(SeparateAccount separateAccount) {
        Map<String, Object> map = new HashMap<>();
        map.put("accountId", separateAccount.getAccountId());
        map.put("memberId", separateAccount.getMemberId());
        map.put("state", separateAccount.getState());
        return adaPayDao.disableAccount(map);
    }

    @Override
    public List<SeparateAccount> getInfoByAccountId(Integer accountId) {
        return adaPayDao.getInfoByAccountId(accountId);
    }


}
